package com.example.spring.controller;

import cn.rsa.aiwangren.annotation.Decrypt;
import cn.rsa.aiwangren.annotation.Encrypt;
import cn.rsa.aiwangren.config.SecretKeyConfig;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    SecretKeyConfig secretKeyConfig;

    @GetMapping("getUser")
    @Encrypt("civil-affairs")
    public String getUser() {
        return secretKeyConfig.toString();
    }

    @PostMapping("decrypt")
    @Decrypt("civil-affairs")
    public String decrypt(@RequestBody JSONObject jsonObject) {
        return jsonObject.toJSONString();
    }
}
